import { useLocation,Navigate} from "react-router-dom";
import React, { ReactNode} from "react";
interface Iprops   {
  children:ReactNode
}
function Private (props:Iprops) {
  var token = sessionStorage.getItem("token");
  var  location = useLocation()
  if(token){
    return <>{props.children}</>
  }else{
    return ( <Navigate to={{pathname:'/login',search:"?redirect="+location.pathname}}></Navigate> );
  }
 
}

export default Private